package bookdemo.MPService;

import bookdemo.domain.Book;
import bookdemo.service.BookService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class MPBookServiceTestCase {
    @Autowired

    private MPBookService bookService;

    @Test
    void testGetById(){
        System.out.println(bookService.getById(1));
    }

    @Test
    void TestUpdate(){
        Book book = new Book();
        book.setId(9);
        book.setName("书x02");
        bookService.updateById(book);

    }


    @Test
    void TestDelete(){
        bookService.removeById(112);

    }


    @Test
    void TestGetall(){

        System.out.println(bookService.list());
    }


    @Test
    void TestGetPage(){
        IPage<Book> page =new Page(1,5);
        bookService.page(page);
        //获取页码
        page.getCurrent();
        //获取页码大小
        page.getSize();
        //获取当前页码
        page.getPages();
        //获取分页数据
        page.getRecords();
        //获取数据数量
        page.getTotal();
        System.out.println(page.getTotal());
    }
}
